package com.hlxt.nj.common;

import com.hlxt.nj.sys.model.TUser;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;


public class LoginUtil {
	
	public static TUser getUser(){
		try{
			ServletRequestAttributes servletRequestAttributes=(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
			if(servletRequestAttributes==null){
				return null;
			}else{
				HttpServletRequest request = servletRequestAttributes.getRequest();
				HttpServletRequest httpreq = (HttpServletRequest) request;
				TUser user = (TUser) httpreq.getSession().getAttribute(BusiConst.SESSION_USER);
				return user;
			}
		}catch(Exception e){
			return null;
		}
	}
}
